home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!gate.demon.co.uk
- From: Justin Lane <justin@redalert.demon.co.uk>
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: random number in assembly
- Date: Thu, 28 Mar 96 00:42:30 GMT
- Organization: Private Node
- Message-ID: <9603280042.AA000cx@redalert.demon.co.uk>
- References: <Pine.NEB.3.91.960327200012.12939A-100000@dirty.cute.fi>
- X-NNTP-Posting-Host: gate.demon.co.uk
- X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
- X-Mail2News-Path: relay-1.mail.demon.net!gate.demon.co.uk
-
- Kristian Slavov (kslavov@dirty.cute.fi) wrote:
- : Hi!
- : Could someone tell me how to get a VERY WELL randomized number?
- : I've tried all kinds of methods but they are not enough random :(
- : To make the problem a little bit harder I need a routine that can be used
- : in loops so that the numbers wouldn't be for ex. 4,8,12,16,20 or
- : 2,3,4,5,6,7. Hope you understood that :)
- :
- : +++++++++++++++++++++++++++++++++++++++++++++
- : + Kristian "Hwmagic" Slavov +
- : + Email: krslavov@freenet.hut.fi --or-- +
- : + kslavov@cute.fi +
- : +++++++++++++++++++++++++++++++++++++++++++++
-
- I was given this routine by garygould@redalert.demon.co.uk but I think he
- may have got it from somewhere else :-
-
- BTW I have never used this routine.
-
- ; (d7)
- ; d7 number range to chosse from
- ; return d7
-
- Randseed DS.B 4
- Random movem.l d0-d1/a0,-(sp)
- move.l d7,d1
- tst.w d1
- beq zer1
- lea Randseed,a0
- move.l (a0),d0
- add.l d0,d0
- bhi.s over
- eori.l #$1d872b41,d0
- over move.l d0,(a0)
- andi.l #$ffff,d0
- divu d1,d0
- swap d0
- move.w d0,d7
- zer1 movem.l (sp)+,d0-d1/a0
- rts
-
-
-
-